package io.vincentwinner.systeminfoapi.dao.impl;

import com.alibaba.fastjson.JSONArray;
import io.vincentwinner.systeminfoapi.dao.IMemoryDao;
import io.vincentwinner.toolset.os.Computer;
import io.vincentwinner.toolset.os.Memory;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @see IMemoryDao
 */
@Repository("memoryDao")
public class MemoryDaoImpl implements IMemoryDao {

    private final Memory memory = Computer.getMemory();
    private final List<Memory.MemoryHardwareInfo> hardInfos = memory.hardwareInfo();

    @Override
    public List<Memory.MemoryHardwareInfo> getMemoryHardwareInfos() {
        return hardInfos;
    }

    @Override
    public Long getPhysicalTotal() {
        return memory.physicalTotal();
    }

    @Override
    public Long getPhysicalFree() {
        return memory.physicalFree();
    }

    @Override
    public Long getPhysicalUsed() {
        return memory.physicalUsed();
    }

    @Override
    public Double getPhysicalUsage() {
        return memory.physicalUsage();
    }

    @Override
    public Long getSwapTotal() {
        return memory.swapTotal();
    }

    @Override
    public Long getSwapFree() {
        return memory.swapFree();
    }

    @Override
    public Long getSwapUsed() {
        return memory.swapUsed();
    }

    @Override
    public Double getSwapUsage() {
        return memory.swapUsage();
    }

}
